<?php

namespace app\home\controller;

use app\admin\model\AppLog;
use think\facade\Db;

class Index
{
    public function index()
    {
        $data = getConfig('admin', 'app_base');
        //  预览图片
        $img = getConfig('admin', 'app_img');
        // 提取所有img字段
        $images = [];
        foreach ($img as $key => $value) {
            if (strpos($key, 'img') === 0 && is_numeric(substr($key, 3)) && !empty($value)) {
                $images[] = $value;
            }
        }
        $download = getConfig('admin', 'app_download');
        $isExist = file_exists(app()->getRootPath() . $download['apkFilePath']);
        $upgradeLog = AppLog::getList();
        return view('index', ['data' => $data, 'images' => $images, 'download' => $download, 'isExist' => $isExist, 'upgradeLog' => $upgradeLog]);
    }
}
